from flask import current_app

class UserArticlesCountStorage(object):
    key = 'count:user:arts'

    @classmethod
    def incr(cls, user_id, increment=1):
        current_app.redis_master.zincrby(cls.key, user_id, increment)

    @classmethod
    def get(cls, user_id):
        # 获取用户发布文章数量
        count = current_app.redis_master.zscore(cls.key, user_id)
        if count is None:
            count = 0
        return int(count)
